package xyz.labmem.base.sys.module.menu.controller

import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import xyz.labmem.base.core.result.RV
import xyz.labmem.base.sys.base.BaseController
import xyz.labmem.base.sys.consts.PathPrefixConst
import xyz.labmem.base.sys.module.menu.entity.response.MenusAllRes
import xyz.labmem.base.sys.module.menu.entity.response.MenusResponse
import xyz.labmem.base.sys.module.menu.service.MenuService

@Api(tags = ["资源弹框"])
@RestController
@RequestMapping("${PathPrefixConst.APP_PATH_PREFIX}zytk")
class Menus_Controller(
    private var menuService: MenuService,
)  : BaseController() {
    private val packagePre = "xyz.labmem.main.modular.app."

    @GetMapping("list")
    @ApiOperation(value = "菜单列表")
    fun list(): RV<List<MenusResponse>> {
        var user = getLoginUser()
        val res = ArrayList<MenusResponse>()
        if(menuService.getAmountByUser("${packagePre}zhgk",user))
            res.add(MenusResponse().apply { id="zhgk";name="综合概述"; })
        if(menuService.getAmountByUser("${packagePre}gmjj",user))
            res.add(MenusResponse().apply { id="gmjj";name="国民经济"; })
        if(menuService.getAmountByUser("${packagePre}xxly",user))
            res.add(MenusResponse().apply { id="xxly";name="新型领域"; })
        if(menuService.getAmountByUser("${packagePre}jtys",user))
            res.add(MenusResponse().apply { id="jtys";name="交通运输"; })
        if(menuService.getAmountByUser("${packagePre}wqzb",user))
            res.add(MenusResponse().apply { id="wqzb";name="武器装备"; })
        if(menuService.getAmountByUser("${packagePre}zzdy",user))
            res.add(MenusResponse().apply { id="zzdy";name="政治动员"; })
        if(menuService.getAmountByUser("${packagePre}rmfk",user))
            res.add(MenusResponse().apply { id="rmfk";name="人民防空"; })
        if(menuService.getAmountByUser("${packagePre}rmwz",user))
            res.add(MenusResponse().apply { id="rmwz";name="人民武装"; })
        return success(res)
    }

    @ApiOperation(value = "查询子列表")
    @GetMapping(value = ["/{path}"])
    fun getInfo(@ApiParam(value = "标识", required = true) @PathVariable path: String): RV<List<MenusAllRes>>{
        return success(menuService.getMoudlByUser("${packagePre}${path}",getLoginUser()))
    }
}